package edu.gdkm.service.impl;

import edu.gdkm.dao.IStudentDao;
import edu.gdkm.pojo.Student;
import edu.gdkm.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StudentServiceImpl implements IStudentService {
    @Autowired
    IStudentDao iStudentDao;
    /**
     * 实现StudentServiceImpl中查看本人可借书数量，最多为5本
     *  public Integer checkBorrowCountByUid(Integer uid)，要求返回可借书数量
     *  提交StudentServiceImpl代码
     * */
    @Override
    public Integer checkBorrowCountByUid(Integer uid) {
        Student student=iStudentDao.getStudentByUid(uid);
        return student==null?0:5-student.getBorrowCount();
    }

    @Override
    public Student getStudentBySid(Integer sid) {
        return iStudentDao.getStudentBySid(sid);
    }
}
